import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:yt_devops/resources/str_res_keys.dart';
import 'package:yt_devops/utils/enums.dart';

class RectangleOperateParameterSettingModel {
  /// 指令集Socket值
  late Map socketMap = {};

  /// 运行参数渲染Map
  late Map<String, TimeParamsItem> timeParameterMap;

  /// 选择器标题
  String pickerTitle = "";

  /// 手动PCS功率控制器
  final manualPCSPower = TextEditingController();

  /// 时段1-执行功率控制器
  final time1PCSPower = TextEditingController();

  /// 时段2-执行功率控制器
  final time2PCSPower = TextEditingController();

  /// 时段3-执行功率控制器
  final time3PCSPower = TextEditingController();

  /// 时段4-执行功率控制器
  final time4PCSPower = TextEditingController();

  /// 时段5-执行功率控制器
  final time5PCSPower = TextEditingController();

  /// 运行参数-手动PCS功率
  List<PCSParamsItem> get runningParameterList {
    return <PCSParamsItem>[
      PCSParamsItem(
        'siteMonitor.manualPCSPower'.tr, //手动PC功率
        'KW',
        manualPCSPower,
      ),
    ];
  }

  /// 运行参数时段及执行功率
  Map<String, TimeParamsItem> getTimeParameterMap() {
    final now = DateTime.now();

    return {
      '1': TimeParamsItem(
        '${ResKey.runningTimeFrame.tr}1',
        now,
        now,
        '',
        '',
        '',
        '',
        'siteMonitor.executionPower'.tr, //执行功率,
        'KW',
        time1PCSPower,
      ),
      '2': TimeParamsItem(
        '${ResKey.runningTimeFrame.tr}2',
        now,
        now,
        '',
        '',
        '',
        '',
        'siteMonitor.executionPower'.tr, //执行功率,
        'KW',
        time2PCSPower,
      ),
      '3': TimeParamsItem(
        '${ResKey.runningTimeFrame.tr}3',
        now,
        now,
        '',
        '',
        '',
        '',
        'siteMonitor.executionPower'.tr, //执行功率,
        'KW',
        time3PCSPower,
      ),
      '4': TimeParamsItem(
        '${ResKey.runningTimeFrame.tr}4',
        now,
        now,
        '',
        '',
        '',
        '',
        'siteMonitor.executionPower'.tr, //执行功率,
        'KW',
        time4PCSPower,
      ),
      '5': TimeParamsItem(
        '${ResKey.runningTimeFrame.tr}5',
        now,
        now,
        '',
        '',
        '',
        '',
        'siteMonitor.executionPower'.tr, //执行功率,
        'KW',
        time5PCSPower,
      ),
    };
  }
}

class PCSParamsItem {
  /// 描述
  String label;

  /// 单位
  String unit;

  /// 控制器
  TextEditingController textEditingController;

  PCSParamsItem(
    this.label,
    this.unit,
    this.textEditingController,
  );
}

class TimeParamsItem {
  /// 描述
  String label;

  /// 开始时间
  DateTime startDateTime;

  /// 结束时间
  DateTime endDateTime;

  /// 开始小时
  String startHour;

  /// 开始分钟
  String startMinute;

  /// 结束小时
  String endHour;

  /// 结束分钟
  String endMinute;

  /// 执行功率
  String executionPower;

  /// 单位
  String unit;

  /// 控制器
  TextEditingController textEditingController;

  TimeParamsItem(
    this.label,
    this.startDateTime,
    this.endDateTime,
    this.startHour,
    this.startMinute,
    this.endHour,
    this.endMinute,
    this.executionPower,
    this.unit,
    this.textEditingController,
  );
}
